package org.uim.cricket.util.io;

import java.io.*;

public class FileOpener {

	private String theFile = null;
	
	public FileOpener(String fileName) {
		theFile = fileName;
	}
	
	public StringBuilder open() throws IOException {
		StringBuilder sb = new StringBuilder();
		
		BufferedReader reader = new BufferedReader(new FileReader(theFile));
		String line = null;
		
		while ((line = reader.readLine()) != null) {
			sb.append(line).append('\n');
		}
		
		reader.close();
		
		return sb;
	}
	
	public StringBuffer openAsBuffer() throws Exception {
		StringBuffer sb = new StringBuffer();
		
		BufferedReader reader = new BufferedReader(new FileReader(theFile));
		String line = null;
		
		while ((line = reader.readLine()) != null) {
			sb.append(line).append('\n');
		}
		
		reader.close();
		
		return sb;
	}
}
